<?php
ob_start();
session_start();
include "checksession.php";
date_default_timezone_set('Asia/Bangkok');
$id_member = $_SESSION["id_member"];
include("../connect.php");

$strSQL = "SELECT * FROM userlog WHERE id_member = '$id_member' ";
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
?>
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Adinop Co., Ltd. was founded as an ingredients importer and local manufacturers’ distributor in 1986. We also function as an exporter of finished products</title>
        <link href="../images/it_service_logo.png" rel="shortcut icon" type="image/x-icon" />
        <link rel="stylesheet" href="../css/style.css"/>
        <script type="text/javascript" src="../js/jquery/jquery.js"></script>
        <script type="text/javascript" src="../js/jquery/jquery.validationEngine.js"></script>
        <link rel="stylesheet" href="../css/validationEngine.jquery.css" type="text/css" />
        <!--<script language="javascript" src="../js/jquery/jquery-1.7.1.min"></script>-->
        <script type="text/javascript" src="../fancybox/fancybox/jquery.mousewheel-3.0.4.pack.js"></script>
        <script type="text/javascript" src="../fancybox/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
        <link rel="stylesheet" type="text/css" href="../fancybox/fancybox/jquery.fancybox-1.3.4.css" media="screen" />
        <link rel="stylesheet" href="../fancybox/style.css" />
        <script type="text/javascript">
            $(function() {
                var objSet = "#txtKeyword";
                var objSetText = "ค้นหาด้วย NO.14-G & Project Name ";
                if ($(objSet).val() == "") {
                    $(objSet).val(objSetText);
                }
                $(objSet).focus(function() {
                    if ($(objSet).val() == objSetText) {
                        $(objSet).val("");
                    }
                }).blur(function() {
                    if ($(objSet).val() == "") {
                        $(objSet).val(objSetText);
                    }
                });
            });
        </script>
        <script type="text/javascript">

            $(document).ready(function() {

                $("#addCom").fancybox({
                    'width': '100%',
                    'height': '100%',
                    'autoScale': true,
                    'scrolling': 'auto',
                    'transitionIn': 'elastic',
                    'transitionOut': 'none',
                    'type': 'iframe',
                    'overlayColor': '#000',
                    'hideOnOverlayClick': false,
                    onCleanup: function() {
                        return window.location.reload();
                    }
                });

                $('a[id^="edit"]').fancybox({
                    'width': '100%',
                    'height': '100%',
                    'autoScale': true,
                    'scrolling': 'auto',
                    'transitionIn': 'elastic',
                    'transitionOut': 'none',
                    'type': 'iframe',
                    'overlayColor': '#000',
                    'hideOnOverlayClick': false,
                    onClosed: function() {
                        parent.location.reload(true);
                    }
                });

                $('a[id^="delete"]').fancybox({
                    'width': '20%',
                    'height': '20%',
                    onStart: function() {
                        return window.confirm('คุณต้องการลบรายการนี้ไหม?');
                    },
                    onClosed: function() {
                        parent.location.reload(true);
                    }
                });

            });
        </script>
    </head>
    <body> 
        <body class="body">
            <table align="center" width="90%">
                <tr>
                    <td colspan="2" class="header" >
                        <img src="../images/logo.png"> </a> <img src="../images/it_service_text.png" width ="150">
                                <hr/>
                                </td>
                                </tr >

                                <tr  valign="top">
                                    <td class="left">
                                        <?php include_once "left.php"; ?>
                                    </td>
                                    <td>
                                        <div align="right">
                                            <form id="searchperson" name="txtKeyword" method="get" action="altServiceComSearch.php">
                                                <input name="txtKeyword" type="text" id="txtKeyword" size="35" class="validate[required]"/>
                <!--                                <input type="hidden" name="hidOK">-->
                                                <input type="image" name="search" id="search" value="submit" src="../images/search.png">
                                            </form>

                                        </div>
                                        <?
                                        ob_start();
                                        include_once '../connect.php';
                                        $strSQL2 = "SELECT * FROM  graphic
                                                             JOIN typegrphic ON graphic.typeGrpId = typegrphic.typeGrpId
                                                             JOIN depart ON graphic.de_id = depart.id
                                                  WHERE graphic.emp_id = '$id_member'   and graphic.grpStatus = 'action'
                                                                 
                                ";
                                        $objQuery2 = mysql_query($strSQL2) or die("Error Query [" . $strSQL2 . "]");
                                        $Num_Rows = mysql_num_rows($objQuery2);
                                        $n = 1;
                                        $Per_Page = 7;   // Per Page

                                        $Page = $_GET["Page"];
                                        if (!$_GET["Page"]) {
                                            $Page = 1;
                                        }

                                        $Prev_Page = $Page - 1;
                                        $Next_Page = $Page + 1;

                                        $Page_Start = (($Per_Page * $Page) - $Per_Page);
                                        if ($Num_Rows <= $Per_Page) {
                                            $Num_Pages = 1;
                                        } else if (($Num_Rows % $Per_Page) == 0) {
                                            $Num_Pages = ($Num_Rows / $Per_Page);
                                        } else {
                                            $Num_Pages = ($Num_Rows / $Per_Page) + 1;
                                            $Num_Pages = (int) $Num_Pages;
                                        }

                                        $strSQL2 .=" order  by grpReuiDate ASC LIMIT $Page_Start , $Per_Page";
                                        $objQuery2 = mysql_query($strSQL2);
                                        ?>

              <div align="right">
                            <a id="addCom" href="addEditGraphic.php">
                                <img src="../images/plus-icon.png" width="40px" >
                            </a>
                                        </div>
                                        <div class="nameTitle">รายการขอออกแบบงานกราฟิค</div>
                                        <table width="100%"  border="0" align="center" cellpadding="1" cellspacing="0" class="simply">
                                            <thead>
                                                <tr>
                                                    <th width="5%">ลำดับ</th>
                                                    <th width="10%">ประเภทงาน</th>    
                                                    <th width="10%">NO.14-G</th> 
                                                    <th width="15%">Project Name</th>
                                                    <th width="10%">รหัสพนักงาน</th>
                                                    <th width="10%">ผู้แจ้ง</th>
                                                    <th width="10%">แผนกฝ่าย</th>                       
                                                    <th width="10%">รายงานผล</th>
                                                    <th width="10%">เจ้าหน้าที่</th>  
                                
                                                    <th width="5%">Report</th>
                                                </tr>
                                            </thead>
                                            <?
                                            while ($objResult2 = mysql_fetch_array($objQuery2)) {
                                                ?>
                                                <tbody>
                                                    <tr>
                                                        <td width="5%">  <?php echo $n++; ?></td>
                                                         <td width="10%"><?= $objResult2["typeGrpName"]; ?></td> 
                                                        <td width="10%"><?= $objResult2["grpNumber"]; ?></td>                                     
                                                        <td width="15%"><?= $objResult2["grpNameProject"]; ?></td>
                                                        <td width="10%"><?= $objResult2["emp_id"]; ?></td>
                                                        <td width="10%"><?= $objResult2["grpnameTh"]; ?></td>
                                                        <td width="10%"><?= $objResult2["departname"]; ?></td>
                                                        <td width="10%"><?= $objResult2["grpStatus"]; ?></td>
                                                        <td width="10%"><?= $objResult2[""]; ?></td>
                                                       
                                                                    <td width="5%"> 
                                                                        <a href="report_graphic.php?grpId=<?= $objResult2["grpId"]; ?>" target="blank">
                                                                            <img src="../images/pdf.png" width="35px" >
                                                                        </a>
                                                                    </td> 
                                                                    </tr>
                                                                    <?
                                                                }
                                                                ?>
                                                                </tbody>
                                                                </table>
                                                                <table width="100%"  border="0" align="center" cellpadding="1" cellspacing="0" class="simply">
                                                                    <tr>
                                                                        <td>
                                                                            <br>
                                                                                Total <?= $Num_Rows; ?> Record : <?= $Num_Pages; ?> Page :
                                                                                <?
                                                                                if ($Prev_Page) {
                                                                                    echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><< Back</a> ";
                                                                                }

                                                                                for ($i = 1; $i <= $Num_Pages; $i++) {
                                                                                    if ($i != $Page) {
                                                                                        echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i'>$i</a> ]";
                                                                                    } else {
                                                                                        echo "<b> $i </b>";
                                                                                    }
                                                                                }
                                                                                if ($Page != $Num_Pages) {
                                                                                    echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>Next>></a> ";
                                                                                }
                                                                                ?>
                                                                        </td>
                                                                    </tr>
                                                                </table>
                                                                </td>
                                                                </tr>  
                                                                <tr>
                                                                    <td colspan="2">
                                                                        <div><a href="../checklogout.php" onclick="return confirm('what do you want Exit')"> <img src="../images/logout.png" width="150px"></img></a></div>
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td class="footer" colspan="2">
                                                                        Powered by Department Technology information Adinop
                                                                    </td>
                                                                </tr>
                                                                </table>
                                                                </body>
                                                                </html>